import * as constants from './constants'
// 初始化仓库的值
const initialState = {
  counter: 100,
  banners: []
}

// reducer函数 用户修改仓库中的值
function reducer(state = initialState, action) {
  switch (action.type) {
    case constants.ADD_NUMBER:
      console.log(action)
      return {
        ...state,
        counter: state.counter + action.num
      }
    case constants.SUB_NUMBER:
      console.log(action)
      return {
        ...state,
        counter: state.counter - action.num
      }
      case constants.CHANGE_BANNERS:
        console.log(action)
        return {
          ...state,
          banners: action.bannes
        }
    default:
      return state
  }
}

export default reducer